﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Theme_3_ActiveClass : PowerCreator.LMS.Web.Base.WebBasePage
{
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    PowerCreator.LMS.Web.Room.Room opRoom = new PowerCreator.LMS.Web.Room.Room();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitPage();
            this.Title = config.GetLanagerValueByKey("theme_menu_ActiveClass", PowerCreator.LMS.Language.LanagetItemType.Page);

            BinderRPT();
        }
    }

    protected override void InitPage()
    {
        lbl_RoomListInfoTitle.Text = GetLanageValueByKey("lbl_ActiveLiveServer_InfoTitle", PowerCreator.LMS.Language.LanagetItemType.WebPage);
        btn_Download.Text = GetLanageValueByKey("web_ActiveLiveServer_gv_c6", PowerCreator.LMS.Language.LanagetItemType.Page);
        base.InitPage();
    }
    private void BinderRPT()
    {
        int dtCount = opRoom.Count(" 1=1");
        string orderby = " ID desc";
        DataTable dt = opRoom.Query("", orderby, dtCount, 1);

        dt.Columns.Add("ImgUrl");
        dt.Columns.Add("RoomUrl");

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i]["TEACHER"].ToString().Trim() == "0")
            {
                dt.Rows[i]["TEACHER"] = "<Stop>";
                dt.Rows[i]["RoomUrl"] = dt.Rows[i]["NAME"].ToString();
                //dt.Rows[i]["RoomUrl"] = "<a href=\"../../web/ActiveLiveServer/RoomInfo.aspx?RoomID=" + dt.Rows[i]["ID"].ToString() + "\" target=\"_blank\">" + dt.Rows[i]["NAME"].ToString() + "</a>";
                dt.Rows[i]["ImgUrl"] = "../../web/ActiveLiveServer/images/stop.gif";
            }
            else
            {
                dt.Rows[i]["RoomUrl"] = "<a href=\"../../web/ActiveLiveServer/RoomInfo.aspx?RoomID=" + dt.Rows[i]["ID"].ToString() + "\" target=\"_blank\">" + dt.Rows[i]["NAME"].ToString() + "</a>";
                dt.Rows[i]["ImgUrl"] = "../../web/ActiveLiveServer/images/play.gif";
            }
        }
        rpt_ActiveLiveServer.DataSource = dt;
        rpt_ActiveLiveServer.DataBind();
    }
    protected void btn_Download_Click(object sender, EventArgs e)
    {
        PowerCreator.LMS.Common.Script.Script.RedirectURL(PowerCreator.LMS.Common.Utils.WebUtils.WebRoot + "/web/broadcast/download/LivePlayer.rar");
    }
}
